home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / I9GMLA (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  1.4 KB  |  32 lines

  1. package com.sun.java.swing.text;
  2.  
  3. import java.awt.Component;
  4. import java.awt.event.ActionEvent;
  5.  
  6. class DefaultEditorKit$EndWordAction extends TextAction {
  7.    private boolean select;
  8.  
  9.    DefaultEditorKit$EndWordAction(String nm, boolean select) {
  10.       super(nm);
  11.       this.select = select;
  12.    }
  13.  
  14.    public void actionPerformed(ActionEvent e) {
  15.       JTextComponent target = ((TextAction)this).getTextComponent(e);
  16.       if (target != null) {
  17.          try {
  18.             int offs = target.getCaretPosition();
  19.             int endOffs = Utilities.getWordEnd(target, offs);
  20.             if (this.select) {
  21.                target.moveCaretPosition(endOffs);
  22.             } else {
  23.                target.setCaretPosition(endOffs);
  24.             }
  25.          } catch (BadLocationException var5) {
  26.             ((Component)target).getToolkit().beep();
  27.          }
  28.       }
  29.  
  30.    }
  31. }
  32.